<template>
  <div class="allbonus">
    <div class="body">
      <div
        v-for="item in bonusList"
        :key="item.id"
        class="item"
        v-click-move
        @click="handleClick(item)"
      >
        <div class="itemTop">
          <NuxtImg :src="item.img" style="width: 100%; height: 100%" />
        </div>
        <div class="itemBottom">
          <div class="titel">
            <div class="titel_icon"></div>
            <div class="titel_span">{{ item.title }}</div>
          </div>
          <div class="btn">{{ lang.detalhes_btn }}</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { getBonus } from "~~/server/api/bonus";
const lang: any = getCurrentPageLang("system");

const bonusList = ref<any[]>([]);

const routeNames = [
  "activity-days-cards",
  "activity-vip",
  "activity-slot",
  "activity-resgatar",
  "activity-tesouro",
  "activity-acumulada",
  "activity-clipdoll",
];

// 同时调用本页面需要用到的所有接口
async function initData() {
  // const [bonus] = await Promise.all([useAsyncData("bonus", getBonus)]);
  // initBonus(bonus);
  initBonus();
}
initData();

// 处理数据
function initBonus(bonus?: any) {
  // bonusList.value = Array.isArray(bonus.data.value) ? bonus.data.value : [];
  bonusList.value = new Array(7).fill({}).map((item, index) => {
    return {
      id: index + 1,
      img: `/images/bonus/${index + 1}.png`,
      title: "Convite Baú do Tesouro - " + (index + 1),
      routeName: routeNames[index],
    };
  });
}

const userStore = useUserStore();
function handleClick(item: any) {
  if (!userStore.isLogin) {
    userStore.changeShowLogin(true);
    return;
  }
  navigateTo({ name: item.routeName });
}
</script>

<style scoped lang="scss">
.allbonus {
  padding: 0.25rem 0.25rem 1rem;
  color: var(--theme-neutral1);
}
.allbonus .body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 0.4rem;
}
.allbonus * {
  transition: all 0.3s ease;
}
.item {
  cursor: pointer;
  width: 100%;
  border-radius: 0.2rem;
  overflow: hidden;
  font-family: Arial;
  font-weight: 700;
  color: var(--theme-neutral1);
  background: #312734;
  border-radius: 0.5rem;
  height: 5rem;
}
.item .itemTop {
  height: 75%;
}
.allbonus .body .item .itemBottom {
  display: flex;
  align-content: center;
  height: 25%;
  padding: 0 0.3rem;
  justify-content: space-between;
  align-items: center;
}
.allbonus .body .item .itemBottom .titel {
  display: flex;
  align-items: center;
  justify-content: left;
  text-align: center;
}
.allbonus .body .item .itemBottom .titel .titel_span {
  font-size: 0.35rem;
}
.allbonus .body .item .itemBottom .btn {
  width: 2rem;
  height: 0.7rem;
  border-radius: 0.1rem;
  background: linear-gradient(270deg, #e151a4 0%, #e66fc8 100%);
  font-size: 0.38rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 400;
}
</style>
